// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Rotate Block Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 10 : TYPE_ROTATEBLOCK

// Function declarations
reserve function RotateBlock_DebugDraw
reserve function RotateBlock_DebugSpawn

// Static Values

// Tables

function RotateBlock_DebugDraw
	DrawSprite(0)
end function


function RotateBlock_DebugSpawn
	temp5 = 10
	temp4 = 0
	CallFunction(DebugMode_SpawnObject)
	object[arrayPos0].drawOrder = 4
	object[arrayPos0].groupID = GROUP_BLOCKS
end function


event ObjectMain
	if object.state == 1
		object.frame = object.value0
		object.frame >>= 3
		object.value0++
		if object.value0 == 32
			object.value0 = 0
			object.state = 0
			object.frame = 0
		end if
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		CallFunction(SpecialSetup_Function10)
		if checkResult != 0
			if object[currentPlayer].value14 == 0
				object[currentPlayer].value14 = 30
				object.state = 1
				PlayerObject_value3 ^= 1
				PlaySfx(SfxName[Rotate Block], 0)
			end if
		end if
	next
end event


event ObjectDraw
	CallFunction(SpecialSetup_Function9)
	DrawSpriteXY(object.frame, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 176, 76)
	SpriteFrame(-12, -12, 24, 24, 176, 176)
	SpriteFrame(-12, -12, 24, 24, 176, 76)
	SpriteFrame(-12, -12, 24, 24, 176, 176)
	foreach (TypeName[Rotate Block], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].groupID = GROUP_BLOCKS
	next
	SetTableValue(TypeName[Rotate Block], DebugMode_ObjCount, DebugMode_TypeTable)
	SetTableValue(RotateBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(RotateBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 176, 76)
end event
